import java.util.Random;
import java.util.Scanner;

public class Test {
    //猜数字游戏
    public static void main(String[] args) {
        //1.随机生成一个数字
        Random random = new Random();  //注意:括号内若填写数字，相当于固定了系统时钟，则随机数则变成固定值
        int randNum = random.nextInt(100) + 100;//会生成[100,200)之间的数
        System.out.println(randNum);
        //2.从键盘获取到猜的数字
        Scanner scan = new Scanner(System.in);
        while(true) {
            System.out.println("请输入要猜的数字：");
            //Scanner scan = new Scanner(System.in);
            int n = scan.nextInt();
        //3.进行比较
            if(n > randNum) {
                System.out.println("猜大了");
            } else if(n < randNum) {
                System.out.println("猜小了");
            } else {
                System.out.println("猜对了");
                break;
            }
        }
    }
    //生成随机数
    public static void main6(String[] args) {
        Random random = new Random();
        int randNum = random.nextInt(100);//会生成[0,100)之间的数
        System.out.println(randNum);
    }


    public static void main5(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextInt()) {
            int n = scan.nextInt();
            System.out.println("n = " +n );
        }
    }


    public static void main4(String[] args) {
        System.out.println("请输入年龄：");
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        System.out.println(n);


        //此时注意： 上一个nextInt 输入完回车后 ，下一个会读取到回车，所以要先读取到空格
        //scan.nextLine();

        System.out.println("请输入姓名：");
        //Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();
        System.out.println(name);
    }

    public static void main3(String[] args) {
        System.out.println("请输入姓名：");
        Scanner scan = new Scanner(System.in);
        //String name = scan.nextLine();
        String name = scan.next();
        System.out.println(name);

        name = scan.next();
        System.out.println(name);
    }
    public static void main2(String[] args) {
        System.out.println("请输入名字：");
        Scanner scan = new Scanner(System.in);
        int name = scan.nextInt();
        System.out.println(name);


        System.out.println("请输入小数：");
        //Scanner scan = new Scanner(System.in);
        float f = scan.nextFloat();
        System.out.println(f);
    }
        public static void main1(String[] args) {
            Scanner scan = new Scanner(System.in);
            int n = scan.nextInt();
            System.out.println(n);
    }
}
